program swap2

    implicit none

    integer :: i, j

    i = 1; j = 2
    call swap(i, j)
    print *, i, j

contains

    pure subroutine swap(a, b)
        integer, intent(inout) :: a, b

        a = ieor(a, b)
        b = ieor(a, b)
        a = ieor(a, b)

    end subroutine swap

end program swap2
!>            2           1